//////////////////////////////////////////////////////////////////////////
//
// GAM203
// Textured cube class
// TexturedCube.h
// 
// Grant Johnson
// Qantm College
// 27/10/2010
//
//////////////////////////////////////////////////////////////////////////

#ifndef TEXTUREDCUBE_H
#define TEXTUREDCUBE_H

#include "Drawable.h"

#include <d3d9.h>
#include <d3d9types.h>

class TexturedCube : public Drawable
{
public:
	// Vertex format we will use to describe our vertices (must match FVF format below)
	struct VertexData
	{
		D3DVECTOR pos;  // XYZ position
		D3DCOLOR col;
		float u,v;  // Texture coordinates (UVs)
	};

	// DirectX's way of identifying what's in our vertex structure (we bitwise OR these values)
	static const DWORD VERTEX_FORMAT_FVF = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1;

public:
	TexturedCube();
	virtual ~TexturedCube();

	//////////////////////////////////////////////////////////////////////////
	// VIRTUAL - Inherited from Drawable
	// For creating the drawable object
	//
	// Paramaters:
	// a_pDevice, the direct3d device
	// a_pTexFileName, a path passed into the function. This can either be used for
	// the texture file name, or for a mesh's file name.
	//
	// Returns false if any step of the creation failed
	// Returns true if created successfully
	//
	//////////////////////////////////////////////////////////////////////////
	virtual bool CreateObject(IDirect3DDevice9* a_pDevice, char* a_pTexFileName);

	//////////////////////////////////////////////////////////////////////////
	// VIRTUAL - Inherited from Drawable
	// For rendering the drawable object
	//
	// Paramaters:
	// a_pDevice, the direct3d device
	//
	// Returns void
	//
	//////////////////////////////////////////////////////////////////////////
	virtual void Render(float a_dt, IDirect3DDevice9* a_pDevice, const RenderParams& a_renderParams);

	//////////////////////////////////////////////////////////////////////////
	// Set the vertices of the cube
	//
	// Paramaters:
	// None
	//
	// Returns false if unable to create
	// Returns true if created successfully
	//
	//////////////////////////////////////////////////////////////////////////
	bool SetVertices();
	
	//////////////////////////////////////////////////////////////////////////
	// Set the indices of the cube
	//
	// Paramaters:
	// None
	//
	// Returns false if unable to create
	// Returns true if created successfully
	//
	//////////////////////////////////////////////////////////////////////////
	bool SetIndices();

protected:
	//File name for the texture to apply
	char* m_pTexFilename;

	//Pointer to the texture to use
	IDirect3DTexture9* m_pTex;

	//The material to use on the object
	D3DMATERIAL9 m_mtl;
};

#endif  // TEXTUREDCUBE_H
